function tax(income) {
    let tax = 0;
    if (income <= 5000) {
      tax = 0;
    } else if (income > 5000 && income <= 8000) {
      tax = (income - 5000) * 0.05;
    } else {
      tax = (income - 5000) * 0.1 + (3000 * 0.05);
    }
    return tax;
  }
  
  console.log(tax(6000)); 
  console.log(tax(9000)); 